extends HBoxContainer
var stats:Stats
@onready var health_bar: TextureProgressBar = $HealthBar
@onready var eased_health_bar: TextureProgressBar = $HealthBar/EasedHealthBar

func load(v:Stats) -> void:
	stats = v
	stats.health_changed.connect(update_health)
	update_health()
	
	tree_exited.disconnect(func()->void:
		stats.health_changed.disconnect(update_health)
	)

func update_health()->void:
	var precentage := float(stats.health) / float(stats.max_health)
	health_bar.value = precentage
	create_tween().tween_property(eased_health_bar,"value",precentage,0.5)
